package lagou.FileTest;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileCharCopyTest {
    public static void main(String[] args) {
        FileReader f1 = null;
        FileWriter f2 = null;
        try {
            f1 = new FileReader("D:/a.txt");
            f2 = new FileWriter("D:/b.txt");
            System.out.println("开始拷贝……");
            int res = 0;
            while((res = f1.read())!=-1){
                f2.write(res);
            }
            System.out.println("拷贝完成分");
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                f2.close();
                f1.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
